home *** CD-ROM | disk | FTP | other *** search
/ The Atari Compendium / The Atari Compendium (Toad Computers) (1994).iso / files / umich / utils / wnx1091.lzh / INIT.S < prev    next >
Text File  |  1991-10-15  |  2KB  |  107 lines

  1. * 8/27/91
  2. *    program is now 1, accessory now 0.  Reverses the way things
  3. *    would work. 
  4. *
  5. * 8/23/91
  6. * NOTE:  progsize is set to 0 if .ACC or .WNX, so these can't be used
  7. * for those type of programs.  This is because I don't want to assume
  8. * the basepage is 256 bytes before the .ACC, but I guess that would be
  9. * safe... 
  10.  
  11. STKSIZE    = 4*1024
  12.  
  13.         XREF    _main
  14.         XREF    __initargcv
  15.         XREF    _exit
  16.         XDEF    stksize,__app,__base,progsize,stack
  17.         XDEF    __argc,__argv,_errno,_seed,_environ
  18.  
  19.         SECTION TEXT
  20.         
  21. START:        lea    START,a5    ;get the address of this code
  22.         sub.l    #$100,a5    ;a5 = ptr to basepage if .PRG or .WNX
  23.         move.l    a5,__base    ;store basepage ptr in base...
  24.         cmp.l    #"XES",40(a5)    ;is p_reserved = "XES"
  25.         beq.s    .start_wnx    ;no, so do .PRG startup code
  26.  
  27.         move.l    a0,d0            
  28.         tst.l    d0        ;is a0 = 0?
  29.         beq.s    .start_prg    ;yes, so .PRG
  30.         
  31.         move.l    a0,__base    ;a0 is ptr to our basepage
  32.         bra    .start_acc    ;no, so .ACC...        
  33.  
  34. .start_wnx:
  35.         move.w    #-1,__app    ;__app=0xffff
  36.         bra    .__START
  37.  
  38.  
  39. .start_prg:    
  40.         move.w    #1,__app    ;__app=0x1
  41.         move.l    4(a7),a0    ;base page
  42.  
  43.         move.l    #stack+STKSIZE,a7
  44.         
  45.         move.l    $c(a0),d0    ;text len
  46.         add.l    $14(a0),d0    ;data len
  47.         add.l    $1c(a0),d0    ;BSS len
  48.         add.l    #$100,d0    ;basepage
  49.         
  50.         move.l    d0,progsize
  51.         
  52.         move.l    d0,-(sp)
  53.         move.l    a0,-(sp)
  54.         clr.w    -(sp)
  55.         move.w    #$4a,-(sp)
  56.         trap    #1        ;shrink memory
  57.         lea    12(sp),sp
  58.  
  59.         bra.s    .__START
  60.  
  61. .start_acc:    
  62.         move.w    #0,__app        ;__app = 0
  63.         move.l    #stack+STKSIZE,a7    ;must have a stack!
  64.  
  65. .__START:    
  66.         move.l    __base,a0
  67.         move.l    44(a0),-(sp)
  68.         pea    128(a0)
  69.         jsr    __initargcv
  70.         addq.l    #8,sp
  71.  
  72.             
  73.         move.l    _environ,-(sp)
  74.         move.l    __argv,-(sp)
  75.         move.w    __argc,-(sp)
  76.         
  77.         jsr    _main
  78.  
  79.         addq.l    #2,sp
  80.  
  81.         cmp.w    #-1,__app
  82.         beq    .wnx
  83.  
  84.         clr.w    -(a7)
  85.         jsr    _exit
  86.  
  87. .wnx
  88.         move.l    #0,-(sp)    ;null parmblk.. we don't know...
  89.         move.w    #39,-(sp)
  90.         move.w    #-1,-(sp)
  91.         trap    #5
  92.  
  93.         SECTION DATA
  94. stksize        dc.l    STKSIZE
  95.  
  96.         SECTION BSS
  97. __app        ds.w    1
  98. __base        ds.l    1
  99. _environ    ds.l    1
  100. __argv        ds.l    1
  101. __argc        ds.w    1
  102. _seed        ds.l    1
  103. _errno        ds.w    1
  104. progsize    ds.l    1
  105.     
  106. stack        ds.b    STKSIZE+2
  107.